import 'package:casdon/core/logger/log.dart';
import 'package:casdon/core/network/business_exception.dart';
import 'package:casdon/modules/me/data/api/service_channel_list_api.dart';
import 'package:casdon/modules/me/data/repository/me_repository.dart';
import 'package:casdon/modules/me/data/repository/me_repository_impl.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class ServiceChannelListUsecase {
  final MeRepository _repository;

  const ServiceChannelListUsecase(this._repository);

  Future<ResponseServiceChannelListApi?> execute() async {
    try {
      final ret = await _repository.getSalesChannels();
      return ret;
    } on BusinessException {
      rethrow;
    } catch (e) {
      Log.e("ServiceChannelListUsecase 失败", e.toString(), StackTrace.current);
    }
  }
}

final serviceChannelListUsecaseProvider = Provider(
  (ref) => ServiceChannelListUsecase(ref.read(meRepositoryProvider)),
);
